﻿using MediatR;
using RBAC.Domain;
using RBAC.Server.Interface;
using Swork03_28.Api.Application.Commands.RoleCommand;

namespace Swork03_28.Api.Application.CommandHandlers.RoleHandler
{
    public class RoleCreateCommandHandler : IRequestHandler<RoleCreateCommand, int>
    {
        private readonly IRoleServer roleServer;

        public RoleCreateCommandHandler(IRoleServer roleServer)
        {
            this.roleServer = roleServer;
        }

        public async Task<int> Handle(RoleCreateCommand request, CancellationToken cancellationToken)
        {
            return await roleServer.CreateRole(new Roles { Name = request.Name });
        }
    }
}
